package com.product.android.ui.activity;

import com.common.android.ui.gif.GifCacheManager;
import com.product.android.business.ApplicationVariable;
import com.product.android.business.service.BaseMsgBroadCastReceiver;
import com.product.android.business.service.ReceiveCallback;
import com.product.android.utils.UserIdentityDialog;

import android.content.IntentFilter;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

public class BaseReceiveActivity extends FragmentActivity implements ReceiveCallback {

	protected BaseMsgBroadCastReceiver baseMsgBroadCastReceiver = null;
	protected boolean registerBroadCast = false;

	@Override
	public void onResume() {
		super.onResume();
		registerReceiverBroad();
		handler_CMD_MyStatus();
		handler_CMD_UserStatus();
		if (ApplicationVariable.INSTANCE.isForceOffline) {
			UserIdentityDialog.dialogForceOffline(this);
			 
		}
		if (ApplicationVariable.INSTANCE.isIdentityExpired) {
			UserIdentityDialog.dialogIdentityExpired(this);
		}
		GifCacheManager.INSTANCE.deActive();
	}
	
	@Override
	protected void onPause() {
		super.onPause();
		unRegisterReceiverBroad();
	}

	protected void unRegisterReceiverBroad() {
		if (registerBroadCast) {
			BaseReceiveActivity.this
					.unregisterReceiver(baseMsgBroadCastReceiver);
			registerBroadCast = false;
		}
	}

	protected void registerReceiverBroad() {
		if (registerBroadCast == false) {
			baseMsgBroadCastReceiver = new BaseMsgBroadCastReceiver(this,this);
			IntentFilter filter = new IntentFilter();
			filter.addAction(ApplicationVariable.INSTANCE.applicationContext.getPackageName()+".msg");
			this.registerReceiver(baseMsgBroadCastReceiver, filter);
			registerBroadCast = true;
		}
	}

	public void handler_CMD_Suggest() {
	}

	public void handler_CMD_635() {
	}

	public void handler_CMD_RemoveGroup(Bundle bundle) {
//		handler_CMD_31();
		handler_CMD_x20004();
	}

	public void handler_CMD_12000() {
	}

	public void handler_CMD_GROUP_MEMBER_REFRESH() {
	}

	public void handler_CMD_39() {
	}

	public void handler_CMD_85674() {
	}

	public void handler_CMD_31() {
	}


	public void handler_CMD_MyStatus() {
	}

	public void handler_CMD_UserStatus() {
	}

	public void handler_CMD_33() {
		UserIdentityDialog.dialogForceOffline(this);
	}


//	public void handler_CMD_9() {
//		handler_CMD_MyStatus();
//		handler_CMD_UserStatus();
//	}

	/**
	 * 通知上线处理
	 */
	public void handler_CMD_36864() {
		handler_CMD_MyStatus();
	}

	/**
	 * 个人状态改变
	 * 
	 * @param bundle
	 */
	public void handler_CMD_16() {
		// ImsSendCommand.getInstance().wy_srv_multi_online(fids.length,fids );
		handler_CMD_MyStatus();
		handler_CMD_UserStatus();
	}

	/**
	 * 好友状态改变
	 * 
	 * @param bundle
	 */
	public void handler_CMD_51() {
		handler_CMD_UserStatus();
	}

	/**
	 * 好友状态改变
	 * 
	 * @param bundle
	 */
	public void handler_CMD_53() {
		handler_CMD_UserStatus();
	}

	public void handler_CMD_5502() {
		UserIdentityDialog.dialogIdentityExpired(this);
	}

	public void handler_CMD_119() {
		handler_CMD_MyStatus();
		handler_CMD_UserStatus();
	}

	public void handler_CMD_49156(Bundle bundle) {
		handler_CMD_UserStatus();
		handler_CMD_MyStatus();
	}

	public void handler_CMD_30010() {
		handler_CMD_MyStatus();
		handler_CMD_UserStatus();
	}

	public void handler_CMD_GROUP_SYSMSG_TYPE_GROUP_INFO_CHANGED(Bundle bundle) {
		if (null != bundle && bundle.containsKey("str")) {
			handler_CMD_GROUP_SYSMSG_TYPE_GROUP_INFO_CHANGED(bundle
					.getString("str"));
		} else {
			handler_CMD_GROUP_SYSMSG_TYPE_GROUP_INFO_CHANGED("");
		}
	}

	public void handler_CMD_GROUP_SYSMSG_TYPE_GROUP_INFO_CHANGED(
			String modifystr) {
	}

	public void handler_CMD_GETAPPINFO() {
	}

	public void handler_CMD_30011() {  //自己头像修改
		handler_CMD_MyStatus();
		handler_CMD_UserStatus();
//		handler_CMD_31();
	}

	@Override
	public void handler_CMD_SHOWLEFT() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void handler_CMD_SHOWRIGHT() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void handler_CMD_89() {
		// TODO Auto-generated method stub
		
	}

	/**
	 * 
	 * @n<b>函数名称</b>     :handler_CMD_12000
	 * @brief	调用时必须super，兼容不处理url的
	 * @see
	 * @since    Ver 1.1
	 * @param  @param url
	 * @<b>作者</b>          :  huangszh
	 * @<b>创建时间</b>      :  2013-11-29上午11:38:25
	 */
	@Override
	public void handler_CMD_12000(String url) {
		handler_CMD_12000();
	}

	public void handler_CMD_x20000() {  //631改为组织树同步
	} 
	public void handler_CMD_x20002() {  //631改为组织树同步
	} 
	public void handler_CMD_x20003() {  //631改为组织树同步
	} 
	public void handler_CMD_x20004() {  //631改为组织树同步
	} 	
	public void handler_CMD_x20005() {  //631改为组织树同步
	} 
}